import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input;
import org.newdawn.slick.geom.Vector2f;
import org.newdawn.slick.state.StateBasedGame;
 
 /**
  * THIS IS A TEST CLASS
  * but it may be adapted for our actual game later on
  * @author Akshay
  *
  */
public class TopDownMovementComponent extends Component {
 
	float direction;
	float speed;
 
	public TopDownMovementComponent( String id )
	{
		this.id = id;
	}
 
	public float getSpeed()
	{
		return speed;
	}
 
	public float getDirection()
	{
		return direction;
	}
 
	@Override
	public void update(GameContainer gc, StateBasedGame sb, int delta) {
 
		float rotation = parent.getRotation();
		float scale = parent.getScale();
		Vector2f position = parent.getPosition();
 
		Input input = gc.getInput();
 
        if(input.isKeyDown(Input.KEY_A))
        {
        	rotation += -0.2f * delta;
        }
 
        if(input.isKeyDown(Input.KEY_D))
        {
        	rotation += 0.2f * delta;
        }
 
        if(input.isKeyDown(Input.KEY_W))
        {
            float hyp = 0.4f * delta;
 
            position.x += hyp * Math.sin(Math.toRadians(rotation));
            position.y -= hyp * Math.cos(Math.toRadians(rotation));
        }
 
		parent.setPosition(position);
		parent.setRotation(rotation);
		parent.setScale(scale);
	}
 
}